
#import "CustomUIASView.h"


@implementation CustomUIASView

@synthesize firstButton;
@synthesize secondButton;
@synthesize thirdButton;
@synthesize cancelButton;
@synthesize fourthButton;
@synthesize isFourthButton;

- (id)initWithFrameAndSource:(CGRect)frame buttonTitles:(NSArray*)titleArr moreThreeButton:(BOOL)isMoreThreeBtn
{
  
  if ((self = [super initWithFrame:frame])) {
    
    self.alpha           = 1.;
    self.backgroundColor = [UIColor colorWithRed:97./255 green:101./255 blue:111./255 alpha:1];
    
    UIImage *buttonImageNormal;
    UIImage *stretchableButtonImageNormal;

    buttonImageNormal            = [UIImage imageNamed:@"large-button.png"];
    stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
     
      self.isFourthButton = isMoreThreeBtn;
      
    self.firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.firstButton.frame           = CGRectMake(10, 10, 301, 46);
    self.firstButton.backgroundColor = [UIColor clearColor];
    [self.firstButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.firstButton setTitle:[titleArr objectAtIndex:0] forState:UIControlStateNormal];
    [self.firstButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
    self.firstButton.titleLabel.font = [UIFont boldSystemFontOfSize:16.0f];
    [self addSubview:self.firstButton];
    
    self.secondButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.secondButton.frame           = CGRectMake(10, (10 + 46 + 5), 301, 46);
    self.secondButton.backgroundColor = [UIColor clearColor];
    [self.secondButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.secondButton setTitle:[titleArr objectAtIndex:1] forState:UIControlStateNormal];
    [self.secondButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
    self.secondButton.titleLabel.font = [UIFont boldSystemFontOfSize:16.0f];
    [self addSubview:self.secondButton];
    
    self.thirdButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.thirdButton.frame           = CGRectMake(10, (secondButton.frame.origin.y + secondButton.frame.size.height + 5), 301, 46);
    self.thirdButton.backgroundColor = [UIColor clearColor];
    [self.thirdButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.thirdButton setTitle:[titleArr objectAtIndex:2] forState:UIControlStateNormal];
    [self.thirdButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
    self.thirdButton.titleLabel.font = [UIFont boldSystemFontOfSize:16.0f];
    [self addSubview:self.thirdButton];
      
      if (isFourthButton) {
          self.fourthButton = [UIButton buttonWithType:UIButtonTypeCustom];
          self.fourthButton.frame           = CGRectMake(10, (thirdButton.frame.origin.y + thirdButton.frame.size.height + 5), 301, 46);
          self.fourthButton.backgroundColor = [UIColor clearColor];
          [self.fourthButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
          [self.fourthButton setTitle:[titleArr objectAtIndex:3] forState:UIControlStateNormal];
          [self.fourthButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
          self.fourthButton.titleLabel.font = [UIFont boldSystemFontOfSize:16.0f];
          [self addSubview:self.fourthButton];
          
          buttonImageNormal            = [UIImage imageNamed:@"large-button-cancel.png"];
          stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
          self.cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
          self.cancelButton.frame           = CGRectMake(10, (fourthButton.frame.origin.y + fourthButton.frame.size.height + 5), 301, 46);
          self.cancelButton.backgroundColor = [UIColor clearColor];
          [self.cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
          [self.cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
          [self.cancelButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
          self.cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:16.0f];
          [self addSubview:self.cancelButton];
      }else {
          buttonImageNormal            = [UIImage imageNamed:@"large-button-cancel.png"];
          stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
          self.cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
          self.cancelButton.frame           = CGRectMake(10, (thirdButton.frame.origin.y + thirdButton.frame.size.height + 5), 301, 46);
          self.cancelButton.backgroundColor = [UIColor clearColor];
          [self.cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
          [self.cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
          [self.cancelButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
          self.cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:16.0f];
          [self addSubview:self.cancelButton];
      }
      
      
      
      
  }
  
  return self;
}

- (void)dealloc {
  [firstButton release];
  [secondButton release];
  [thirdButton release];
  [cancelButton release];
    if (fourthButton) {
        [fourthButton release];
    }
  [super dealloc];
}

@end